package com.key.win.business.chat.eums;

import com.baomidou.mybatisplus.annotation.EnumValue;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.key.win.base.enumjson.TextureEnumSerializerCode;
import org.apache.commons.lang3.StringUtils;

@JsonSerialize(using = TextureEnumSerializerCode.class)
public enum ImMessageTargetEnum {
    FRIEND(0, "好友消息"),
    GROUP(1, "群消息"),
    APPLY(2, "申请消息"),
    SYSTEM(3, "系统消息");
    @EnumValue
    private int code;
    private String text;

    private ImMessageTargetEnum(int code, String text) {
        this.code = code;
        this.text = text;
    }


    public int getCode() {
        return code;
    }

    public String getText() {
        return text;
    }

    public static ImMessageTargetEnum getImMessageTargetEnumByName(String name) {
        if (StringUtils.isNotBlank(name)) {
            for (ImMessageTargetEnum ime : ImMessageTargetEnum.values()) {
                if (ime.name().equals(name)) {
                    return ime;
                }
            }
        }
        return null;
    }
}
